<template>
	<!--供应商信息-物资供应商列表-->
	<a-card :bordered="false">
		<!-- 查询区域 -->
		<div class="table-page-search-wrapper">
			<a-form layout="inline" @keyup.enter.native="searchQuery">
				<a-row :gutter="24">

					<a-col :md="6" :sm="12">
						<a-form-item label="供应商名称">
							<a-input placeholder="输入名称模糊查询" v-model="queryParam.name"></a-input>
						</a-form-item>
					</a-col>
					<a-col :md="6" :sm="12">
						<a-form-item label="主营产品">
							<a-input placeholder="输入主营产品" v-model="queryParam.mainProduct"></a-input>
						</a-form-item>
					</a-col>
					<a-col :md="6" :sm="12">
						<a-form-item label="联系人">
							<a-input placeholder="输入联系人" v-model="queryParam.relation"></a-input>
						</a-form-item>
					</a-col>
					<a-col :md="6" :sm="12">
						<a-form-item label="手机号">
							<a-input placeholder="输入手机号" v-model="queryParam.phone"></a-input>
						</a-form-item>
					</a-col>
					<a-col :xl="8" :md="8" :sm="12">
						<a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
							<j-date v-model="queryParam.queryStartTime" :showTime="true" date-format="YYYY-MM-DD "
								style="width: 25%" placeholder="请选择开始时间"></j-date>
							<span style="width: 10px">~</span>
							<j-date v-model="queryParam.queryEndTime" :showTime="true" date-format="YYYY-MM-DD"
								style="width: 25%" placeholder="请选择结束时间"></j-date>
						</a-form-item>
					</a-col>
					<a-col :md="6" :sm="8">
						<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
							<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
							<a-button type="primary" @click="searchReset" icon="reload"
								style="margin-left: 8px">重置</a-button>
						</span>
					</a-col>
				</a-row>
			</a-form>
		</div>
		<!-- 查询区域-END -->

		<!-- 操作按钮区域 -->

		<!-- table区域-begin -->
		<a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns"
			:dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
			@change="handleTableChange">
			<template slot="htmlSlot" slot-scope="text">
				<div v-html="text"></div>
			</template>
			<template slot="imgSlot" slot-scope="text,record">
				<span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
				<img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
					style="max-width:80px;font-size: 12px;font-style: italic;" />
			</template>
			<template slot="fileSlot" slot-scope="text">
				<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
				<a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
					下载
				</a-button>
			</template>
			<template slot="action" slot-scope="text, record">
				<a @click="handleScore(record,'supplierrecord')">缴费记录</a>
				<a-divider type="vertical" />
				<a @click="handleDetail(record)">详情</a>
				<a-divider type="vertical" />
				<a @click="handleScore(record,'suppliereditfees')">缴费改分</a>
				<a-divider type="vertical" />
				<a @click="handleScore(record,'supplierdetailfees')">评分记录</a>
			</template>
		</a-table>
		</div>
		<wt-supplier-modal ref="modalForm" @ok="modalFormOk"></wt-supplier-modal>
		<score-modal ref="modalForm2" @ok="modalFormOk"></score-modal>
	</a-card>
</template>

<script>
	import '@/assets/less/TableExpand.less'
	import {
		mixinDevice
	} from '@/utils/mixin'
	import {
		JeecgListMixin
	} from '@/mixins/JeecgListMixin'
	import WtSupplierModal from './components/WtSupplierModal.vue'
	import ScoreModal from './components/ScoreModal.vue'
	export default {
		name: 'WtSupplierList',
		mixins: [JeecgListMixin, mixinDevice],
		components: {
			WtSupplierModal,
			ScoreModal
		},
		data() {
			return {
				description: '供应商管理页面',
				// 表头
				columns: [{
						title: '创建时间',
						dataIndex: 'createTime',
						align: "center",

					},
					{
						title: '供应商名称',
						align: 'center',
						dataIndex: 'name',
					},

					{
						title: '联系人',
						align: 'center',
						dataIndex: 'relation',
					},
					{
						title: '联系电话',
						align: 'center',
						dataIndex: 'phone',
					},
					{
						title: '主营产品',
						align: 'center',
						dataIndex: 'mainProduct',
					},
					{
						title: '地址',
						align: 'center',
						dataIndex: 'address',
					},
					{
						title: '基础评分',
						align: 'center',
						dataIndex: 'score',
					},
					{
						title: '运维最新评分',
						align: 'center',
						dataIndex: 'operationScore',
					},
					{
						title: '操作',
						dataIndex: 'action',
						align: 'center',
						fixed: 'right',
						width: 147,
						scopedSlots: {
							customRender: 'action'
						},
					},
				],
				url: {
					list: '/wtSupplier/list',
					delete: '/wtSupplier/delete',
					deleteBatch: '/wtSupplier/deleteBatch',
					exportXlsUrl: '/wtSupplier/exportXls',
					importExcelUrl: '/wtSupplier/importExcel',
				},
				dictOptions: {},
				superFieldList: [],
				queryParam: {
					type: '0',
					scoreType: '2'
				},
			}
		},
		created() {
			this.getSuperFieldList()
		},
		computed: {
			importExcelUrl: function() {
				return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
			},
		},
		methods: {
			handleScore(record, type) {
				if (type === 'suppliereditfees') {
					this.$refs.modalForm2.title = '缴费改分';
					this.$refs.modalForm2.disableSubmit = false;
				} else if (type === 'supplierdetailfees') {
					this.$refs.modalForm2.title = '评分记录';
					this.$refs.modalForm2.disableSubmit = true;
				} else if(type === 'supplierrecord'){
					this.$refs.modalForm2.title = '缴费记录';
					this.$refs.modalForm2.disableSubmit = true;
				}
				this.$refs.modalForm2.pageType = type;
				this.$refs.modalForm2.edit(record);
			},
			initDictConfig() {},
			getSuperFieldList() {
				let fieldList = []
				fieldList.push({
					type: 'string',
					value: 'name',
					text: '名称',
					dictCode: ''
				})
				fieldList.push({
					type: 'int',
					value: 'type',
					text: '0经营产品1施工',
					dictCode: ''
				})
				fieldList.push({
					type: 'string',
					value: 'relation',
					text: '联系人',
					dictCode: ''
				})
				fieldList.push({
					type: 'string',
					value: 'phone',
					text: '电话',
					dictCode: ''
				})
				fieldList.push({
					type: 'string',
					value: 'address',
					text: '地址',
					dictCode: ''
				})
				fieldList.push({
					type: 'string',
					value: 'score',
					text: '评分',
					dictCode: ''
				})
				this.superFieldList = fieldList
			},
		},
	}
</script>
<style scoped>
	@import '~@assets/less/common.less';
</style>